<?php

namespace App\Http\Controllers\Api\Open;

use App\Models\MoneyLog;

class IndexController extends BaseController
{
    public function index()
    {
        $user = $this->getUser();

        $data['new_fans'] = $user->followers()->where('followables.created_at','>',date("Y-m-d",time()))->count();

        $data['today_money'] = MoneyLog::query()->where('user_id', $user->id)
            ->whereIn('type', [MoneyLog::LIVEROOM_LECTURE_GOODS, MoneyLog::LIVEROOM_CHANNEL_GOODS, MoneyLog::LIVEROOM_VIP_GOODS, MoneyLog::LIVEROOM_DOC_GOODS])
            ->where('money', '>', 0)
            ->where('day', date("Ymd", time()))
            ->sum('money');
        $data['money'] = $user->money;
        $data['liveroom_money'] = $user->liveroom_sum_money;


        return $this->success($data);

    }

}